using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static UnityEngine.EventSystems.EventTrigger;
using static UnityEngine.GraphicsBuffer;

/// <summary>
/// �����˺�Ч��
/// </summary>
[CreateAssetMenu(menuName = "创建ScriptableObject/Effect/DamageEffectData")]
public class DamageEffectData : InstantEffectData
{
    public float multiplier = 1f;

    public override void Execute(Entity caster, Entity target, params object[] args)
    {
        var attackData = caster.AttackComponent.AttackData;
        long baseDamage = attackData.Damage;
        long dmg = (long)Math.Round(baseDamage * multiplier);
        target.FSMComponent.ChangeStatus(FSMType.Hit, dmg);
        
        // 受到伤害时变红
        float colorDuration = attackData != null ? attackData.Duration : 0.2f;
        target.SetColor(Color.red, colorDuration);
    }
}
